/**
 * 事项发布
 */

import request, { requestNoRes } from '@/utils/request'

// import config from './config.js'

// const baseApi = config.baseApi

/**
 * GET 获取事项发布列表
 * @returns {Promise<Result>}
 */
export function getItemPublishList (params) {
  return request({
    url: '/event/type/item/info/page/publish',
    method: 'get',
    params
  })
}

/**
 * GET 历史流程查询
 * @returns {Promise<Result>}
 */
export function getItemHistoryProcess (params) {
  return request({
    // url: '/event/type/apply/queryHistoryFlow',
    url: '/onm/event/type/queryHistoryFlow',
    method: 'get',
    params
  })
}
/**
 * GET 事项申请列表
 * @returns {Promise<Result>}
 */
export function getItemApplyList (params) {
  return request({
    url: '/event/type/apply/query',
    method: 'get',
    params
  })
}
/**
 * GET 新版事项申请列表
 * @returns {Promise<Result>}
 */
export function getEventApplyList (params) {
  return request({
    url: '/onm/event/type/getEventApplyList',
    method: 'get',
    params
  })
}
/**
 * GET 提交事项变动申请
 * @returns {Promise<Result>}
 */
 export function changeSubmit (data) {
  return request({
    url: '/onm/event/type/item/change/submit',
    method: 'post',
    data
  })
}

/**
 * GET 变动申请事项列表
 * @returns {Promise<Result>}
 */
 export function changeItemList (params) {
  return request({
    url: '/onm/event/type/changeItemList',
    method: 'get',
    params
  })
}
/**
 * GET 事项申请删除
 * @returns {Promise<Result>}
 */
export function deleteItemApply (itemCode) {
  return request({
    url: `/event/type/apply/delItemInfo?itemCode=${itemCode}`,
    method: 'get'
  })
}
/**
 * GET 事项审核
 * @returns {Promise<Result>}
 */
export function auditItemApply (data) {
  return request({
    // url: '/event/type/apply/submit',
    url: '/onm/event/type/submit',
    method: 'post',
    data
  })
}

/**
 * POST 更改事件发布状态
 * @returns {Promise<Result>}
 */
export function updatePublish (data) {
  return request({
    // url: '/event/type/item/info/update/publish',
    url: '/onm/event/type/publishEvent',
    method: 'post',
    data
  })
}


/**
 * POST 保存同步信息
 * @returns {Promise<Result>}
 */
export function saveSynInfo (params) {
  return requestNoRes({
    url: '/event/type/synchronized/saveSynInfo',
    method: 'get',
    params,
    timeout: 0 // 同步接口不设置超时
  })
}

/**
 * POST 审批界面提交
 * @returns {Promise<Result>}
 */
export function applySubmit (data) {
  return request({
    // url: '/event/type/apply/submit',
    url: '/onm/event/type/submit',
    method: 'post',
    data
  })
}

// 全量查询
export function getAllApplyList (params) {
  return request({
    url: '/onm/event/type/fullItemList',
    method: 'get',
    params,
  })
}

// 全量查询导出
export function itemExport (params) {
  return request({
    url: '/onm/event/type/item/export/itemExport',
    method: 'get',
    params,
    responseType: 'blob'
  })
}